package com.effective.java.inheritence;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * This is a forwarding class containing merely forwarding methods.
 * 
 * @author andreas.landerer
 * 
 * @param <E>
 *            any type
 */
public class ForwardingSet<E> implements Set<E> {

	/**
	 * reference to the set
	 */
	private final Set<E> set;

	public ForwardingSet(Set<E> set) {

		if (set == null) {
			throw new IllegalArgumentException("Mandatory input parameter 'set' is NULL!");
		}
		this.set = set;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean add(E arg0) {

		return this.set.add(arg0);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean addAll(Collection<? extends E> arg0) {

		return this.set.addAll(arg0);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void clear() {

		this.set.clear();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean contains(Object arg0) {

		return this.set.contains(arg0);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean containsAll(Collection<?> arg0) {

		return this.set.containsAll(arg0);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean isEmpty() {

		return this.set.isEmpty();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Iterator<E> iterator() {

		return this.set.iterator();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean remove(Object arg0) {

		return this.set.remove(arg0);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean removeAll(Collection<?> arg0) {

		return this.set.removeAll(arg0);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean retainAll(Collection<?> arg0) {

		return this.set.retainAll(arg0);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public int size() {

		return this.set.size();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Object[] toArray() {

		return this.set.toArray();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public <T> T[] toArray(T[] arg0) {

		return this.set.toArray(arg0);
	}
}
